 <?php
//get user request
$userRequest = $_SERVER['QUERY_STRING']; 
//parse the page request and other GET variables
$parsedData = explode('&' , $userRequest);

//the request page is the first element
$requestPage = array_shift($parsedData);

// analysis of the remainder of the $ _GET
$getVars = array();
foreach ($parsedData as $dataArgument)
{
	//explode GET vars along '=' symbol to separate variable, values
	list($variable , $value) = explode('=' , $dataArgument);
	$getVars[$variable] = $value;
}

//create a patch with controllers
$filePath = SERVER_ROOT . '/controllers/' . basename($requestPage) . '.php';

//get target
if (file_exists($filePath))
{
    include_once($filePath);

    //modify page to fit naming convention
    $controllerClass = ucfirst($requestPage) . '_Controller';

    //instantiate the appropriate class
    if (class_exists($controllerClass))
    {
        $applicationController = new $controllerClass;
    }
    else
    {
        die('class does not exist!');
    }
}
else
{
	 
    die('page does not exist!');
}

$applicationController->main($getVars);